package org.hyf.inspur.LessonDesin.clear.wordcount;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.Iterator;

public class WordCountsorReducer extends Reducer<Text, Text, Text, LongWritable> {

    protected void reduce(IntWritable key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
        Iterator<Text> it = values.iterator();
        long count = 0;
        while (it.hasNext()) {
            Text temp = it.next();
            count++;
        }

        context.write(new Text(String.valueOf(key)), new LongWritable(count));
    }
}
